
AM_LDFLAGS = -version-info 11:0:0

CXXFLAGS_DBG += $(ACSM_ANY_WERROR_FLAG) $(ACSM_ANY_PARANOID_FLAGS)
CXXFLAGS_DEVEL += $(ACSM_ANY_WERROR_FLAG) $(ACSM_ANY_PARANOID_FLAGS)
CXXFLAGS_OPROF += $(ACSM_ANY_WERROR_FLAG) $(ACSM_ANY_PARANOID_FLAGS)
CXXFLAGS_OPT += $(ACSM_ANY_WERROR_FLAG) $(ACSM_ANY_PARANOID_FLAGS)
CXXFLAGS_PROF += $(ACSM_ANY_WERROR_FLAG) $(ACSM_ANY_PARANOID_FLAGS)


#----------------------------------------------
# List of source files to build dynamic library
#----------------------------------------------
timpi_SOURCES =

# parallel
timpi_SOURCES += parallel/src/communicator.C
timpi_SOURCES += parallel/src/message_tag.C
timpi_SOURCES += parallel/src/request.C

# utilities
timpi_SOURCES += utilities/src/semipermanent.C
timpi_SOURCES += utilities/src/timpi_assert.C
timpi_SOURCES += utilities/src/timpi_init.C
timpi_SOURCES += utilities/src/timpi_version.C

#------------------------------------------
# List of library configurations to compile
#------------------------------------------

lib_LTLIBRARIES =
bin_PROGRAMS    =

if BUILD_DBG_MODE
  lib_LTLIBRARIES            += libtimpi_dbg.la
  libtimpi_dbg_la_SOURCES  = $(timpi_SOURCES)
  libtimpi_dbg_la_CPPFLAGS = $(CPPFLAGS_DBG) $(AM_CPPFLAGS)
  libtimpi_dbg_la_CXXFLAGS = $(CXXFLAGS_DBG)
  bin_PROGRAMS               += timpi_version-dbg
endif

if BUILD_DEVEL_MODE
  lib_LTLIBRARIES              += libtimpi_devel.la
  libtimpi_devel_la_SOURCES  = $(timpi_SOURCES)
  libtimpi_devel_la_CPPFLAGS = $(CPPFLAGS_DEVEL) $(AM_CPPFLAGS)
  libtimpi_devel_la_CXXFLAGS = $(CXXFLAGS_DEVEL)
  bin_PROGRAMS                 += timpi_version-devel
endif

if BUILD_OPT_MODE
  lib_LTLIBRARIES            += libtimpi_opt.la
  libtimpi_opt_la_SOURCES  = $(timpi_SOURCES)
  libtimpi_opt_la_CPPFLAGS = $(CPPFLAGS_OPT) $(AM_CPPFLAGS)
  libtimpi_opt_la_CXXFLAGS = $(CXXFLAGS_OPT)
  bin_PROGRAMS               += timpi_version-opt
endif

if BUILD_PROF_MODE
  lib_LTLIBRARIES             += libtimpi_prof.la
  libtimpi_prof_la_SOURCES  = $(timpi_SOURCES)
  libtimpi_prof_la_CPPFLAGS = $(CPPFLAGS_PROF) $(AM_CPPFLAGS)
  libtimpi_prof_la_CXXFLAGS = $(CXXFLAGS_PROF)
  bin_PROGRAMS                += timpi_version-prof
endif

if BUILD_OPROF_MODE
  lib_LTLIBRARIES              += libtimpi_oprof.la
  libtimpi_oprof_la_SOURCES  = $(timpi_SOURCES)
  libtimpi_oprof_la_CPPFLAGS = $(CPPFLAGS_OPROF) $(AM_CPPFLAGS)
  libtimpi_oprof_la_CXXFLAGS = $(CXXFLAGS_OPROF)
  bin_PROGRAMS                 += timpi_version-oprof
endif


#----------------------------
# INCLUDES we want distributed
#----------------------------
includedir = $(prefix)/include/timpi
include_HEADERS =

# algorithms
include_HEADERS += algorithms/include/timpi/parallel_sync.h

# parallel
include_HEADERS += parallel/include/timpi/attributes.h
include_HEADERS += parallel/include/timpi/communicator.h
include_HEADERS += parallel/include/timpi/data_type.h
include_HEADERS += parallel/include/timpi/message_tag.h
include_HEADERS += parallel/include/timpi/op_function.h
include_HEADERS += parallel/include/timpi/packing_decl.h
include_HEADERS += parallel/include/timpi/packing_forward.h
include_HEADERS += parallel/include/timpi/packing.h
include_HEADERS += parallel/include/timpi/parallel_communicator_specializations
include_HEADERS += parallel/include/timpi/parallel_implementation.h
include_HEADERS += parallel/include/timpi/post_wait_copy_buffer.h
include_HEADERS += parallel/include/timpi/post_wait_delete_buffer.h
include_HEADERS += parallel/include/timpi/post_wait_dereference_shared_ptr.h
include_HEADERS += parallel/include/timpi/post_wait_dereference_tag.h
include_HEADERS += parallel/include/timpi/post_wait_free_buffer.h
include_HEADERS += parallel/include/timpi/post_wait_unpack_buffer.h
include_HEADERS += parallel/include/timpi/post_wait_unpack_nested_buffer.h
include_HEADERS += parallel/include/timpi/post_wait_work.h
include_HEADERS += parallel/include/timpi/request.h
include_HEADERS += parallel/include/timpi/serial_implementation.h
include_HEADERS += parallel/include/timpi/standard_type_forward.h
include_HEADERS += parallel/include/timpi/standard_type.h
include_HEADERS += parallel/include/timpi/status.h

# utilities
include_HEADERS += utilities/include/timpi/ignore_warnings.h
include_HEADERS += utilities/include/timpi/semipermanent.h
include_HEADERS += utilities/include/timpi/timpi.h
include_HEADERS += utilities/include/timpi/timpi_assert.h
include_HEADERS += utilities/include/timpi/timpi_call_mpi.h
include_HEADERS += utilities/include/timpi/timpi_init.h
include_HEADERS += utilities/include/timpi/restore_warnings.h

# Needs to be builddir since this is generated by configure
include_HEADERS += $(top_builddir)/src/utilities/include/timpi/timpi_version.h
include_HEADERS += $(top_builddir)/src/utilities/include/timpi/timpi_config.h

# Version app
timpi_version_opt_SOURCES = apps/version.C
timpi_version_opt_LDADD = libtimpi_opt.la

timpi_version_oprof_SOURCES = apps/version.C
timpi_version_oprof_LDADD = libtimpi_oprof.la

timpi_version_prof_SOURCES = apps/version.C
timpi_version_prof_LDADD = libtimpi_prof.la

timpi_version_devel_SOURCES = apps/version.C
timpi_version_devel_LDADD = libtimpi_devel.la

timpi_version_dbg_SOURCES = apps/version.C
timpi_version_dbg_LDADD = libtimpi_dbg.la

#--------------------------------------
#Local Directories to include for build
#--------------------------------------
AM_CPPFLAGS  = $(timpi_optional_INCLUDES)
AM_CPPFLAGS += -I$(top_srcdir)/src/algorithms/include
AM_CPPFLAGS += -I$(top_srcdir)/src/parallel/include
AM_CPPFLAGS += -I$(top_srcdir)/src/utilities/include
AM_CPPFLAGS += -I$(top_builddir)/src/utilities/include #timpi_version.h, timpi_config.h

LIBS        += $(timpi_optional_LIBS)


# Note that for "make test_headers" this DEFAULT_HEADERS_TO_TEST business allows us
# to selectively choose individual HEADERS_TO_TEST in the test_headers.sh script,
# e.g.
# $ make HEADERS_TO_TEST="numerics/parsed_function.h  base/auto_ptr.h" test_headers
test_headers:
	@echo " "
	@echo "Checking for standalone headers in source tree $(top_builddir)/include in OPT mode ..."
	@echo " "
	@CXX="$(CXX)" DEFAULT_HEADERS_TO_TEST="$(include_HEADERS)" \
          test_CXXFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS_OPT) $(CXXFLAGS_OPT) -I$(top_builddir)/include" \
	  $(top_srcdir)/bin/test_headers.sh
	@echo " "
	@echo "Checking for standalone headers in source tree $(top_builddir)/include in DEVEL mode ..."
	@echo " "
	@CXX="$(CXX)" DEFAULT_HEADERS_TO_TEST="$(include_HEADERS)" \
          test_CXXFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS_DEVEL) $(CXXFLAGS_DEVEL) -I$(top_builddir)/include" \
	  $(top_srcdir)/bin/test_headers.sh
	@echo " "
	@echo "Checking for standalone headers in source tree $(top_builddir)/include in DBG mode ..."
	@echo " "
	@CXX="$(CXX)" DEFAULT_HEADERS_TO_TEST="$(include_HEADERS)" \
          test_CXXFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS_DBG) $(CXXFLAGS_DBG) -I$(top_builddir)/include" \
	  $(top_srcdir)/bin/test_headers.sh
